//
//  NewPasswordView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/31.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class NewPasswordView: UIView {
    var password:UITextField!//电话号码输入框
    var passwordAgain:UITextField!//密码输入框
    var logButton:UIButton!//登录按钮
    
    
    override init(frame: CGRect) {
        password = UITextField()
        passwordAgain = UITextField()
        logButton = UIButton()
        super.init(frame: frame)
        self.createNewPasswordTextF()
        self.createLogButton()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.password.resignFirstResponder()
        self.passwordAgain.resignFirstResponder()
    }
    
    //创建两个输入新密码框
    func createNewPasswordTextF(){
        password.frame = CGRect(x: 32*SCALEW, y: 27*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        password.placeholder = "请输入新密码"
        password.keyboardType = .Default
        password.secureTextEntry = true
        password.font = BaseFunc.getSystemFont(14.5)
        password.backgroundColor = UIColor.whiteColor()
        let view1 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        password.leftView = view1
        password.leftViewMode = .Always
        password.layer.borderWidth = 1
        password.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        password.layer.cornerRadius = 5
        self.addSubview(password)
        
        passwordAgain.frame = CGRect(x: 32*SCALEW, y: 82*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        passwordAgain.placeholder = "请再次输入新密码"
        passwordAgain.keyboardType = .Default
        passwordAgain.secureTextEntry = true
        passwordAgain.font = BaseFunc.getSystemFont(14.5)
        passwordAgain.backgroundColor = UIColor.whiteColor()
        let view2 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        passwordAgain.leftView = view2
        passwordAgain.leftViewMode = .Always
        passwordAgain.layer.borderWidth = 1
        passwordAgain.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        passwordAgain.layer.cornerRadius = 5
        passwordAgain.secureTextEntry = true
        self.addSubview(passwordAgain)
        
        
    }
    
    //创建登录按钮
    func createLogButton(){
        logButton.frame = CGRect(x: 33*SCALEW, y: 145*SCALEH, width: 309*SCALEW, height: 50*SCALEH)
        logButton.titleLabel?.font = BaseFunc.getCustomFont(18)
        logButton.setTitle("确定并登录", forState: UIControlState())
        logButton.backgroundColor = UIColor.blackColor()
        logButton.layer.cornerRadius = 5
        self.addSubview(logButton)
    }
}
